<?php


if (!defined("EXPONENT")) exit("");

$gallery = null;
if (isset($_GET['gid'])) {
	$gallery = $db->selectObject("imagegallery_gallery","id=".$_GET['gid']);
	if ($gallery) {
		$loc = unserialize($gallery->location_data);
	} else {
	   $gallery->gallery_collection=0;
  }
}

if (!empty($gallery)) {
	if (exponent_permissions_check('manage',$loc)) {
		if (!defined("SYS_FORMS")) require_once(BASE."subsystems/forms.php");
		exponent_forms_initialize();
		
		$form = new form();
		$form->location($loc);
		$form->meta("action","save_multiple");
		$form->meta("count",$_GET['count']);
		$form->meta("gid",$_GET['gid']);
		$load_js = true;
		for ($i = 0; $i < $_GET['count']; $i++) {
			if ($i) $form->register($i,"",new htmlcontrol("<hr size='1' />"));
			$form->register("name$i","Name",new textcontrol());
			$form->register("alt$i","Alt Tag",new textcontrol());
			$form->register("file{$i}",'Image',new ajax_select_file("file{$i}",$gallery->gallery_collection,-1,$load_js));
			
			if ($load_js)  $load_js=false;
		}
		$form->register("submit","",new buttongroupcontrol("Upload","","Cancel"));
		
		$template = new template("imagegallerymodule","_form_multiple",$loc);
		$template->assign("form_html",$form->toHTML());
		$template->output();
	} else {
		echo SITE_403_HTML;
	}
} else {
	echo SITE_404_HTML;
}

?>
